#ifndef __MEMORY_POOL_H_
#define __MEMORY_POOL_H_

#define NODESIZE 1024
#define NODECNT 8

#include <string.h>

class MemoryPool
{
public:
    MemoryPool();
    ~MemoryPool();

public:
    /* 分配空间 */
    void *AllocateNum();

    /* 释放空间 */
    void free(void *ptr);

private:
    struct UseNode
    {
        char Node[NODESIZE];
        UseNode *next;
    };

    /* 块 */
    struct Block
    {
        UseNode node[NODECNT];
        Block *next;
    };

private:
    /* 大内存块 */
    Block *m_blockHead;
    /* 小内存块 */
    UseNode *m_nodeHead;
};

#endif // __MEMORY_POOL_H_
